import { Validator } from 'vee-validate'

export default function created() {
    const dict = {
        custom: {
            room_name: {
                required: '房间名不能为空',
                min: '房间名至少由2个字符组成'
            },
            username: {
                required: '用户名不能为空',
                min: '用户名至少由2个字符组成'
            },
            password: {
                required: '密码不能为空',
                min: '密码最少为6个字符',
                max: '密码最多为18个字符',
                confirmed: '两次密码不一致',
            },
            odds: {
                required: '默认赔率不能为空',
                numeric: '赔率只能为数字',
            },
            goldRatio: {
                required: '金币比率不能为空',
                numeric: '金币比率为数字',
            },
            endTime: {
                required: '租期不能为空',
                date_format: '租期格式不对',
            },
            link: {
                url: '盘口链接格式不对',
            }

        }
    };
    Validator.localize('custom', dict);
    this.validator = new Validator({
        room_name: 'required|min:2',
        username: 'required|min:2',
        password: 'min:6|max:18',
        odds: 'required|numeric',
        goldRatio: 'required|numeric',
        endTime: 'required|date_format:YYYY-MM-DD',
        link: 'url',

    });
    this.$set(this, 'errors', this.validator.errors);
}